<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>冒泡排序</title>
</head>
<body>

</body>
<script>
   var arr=[];
   arr.push(10);
   arr.push(9);  // i =3
   arr.push(8);
   arr.push(7);
   arr.push(6);



   /*
     * i=0
     * i=1
     * i=2
     * i=3
   * */

   for(var i = 0; i<arr.length-1;i++){
     for(var j=0;j<arr.length-1-i;j++){
         if(arr[j]>arr[j+1]){
             var temp = arr[j];
             arr[j] = arr[j+1];
             arr[j+1] = temp;
         }
     }

   }



   console.log(arr);


   /*
   *  如何实现员工按照年龄排序
   * */

   var employees = [];
   employees.push({
        name:'Mart',
        age:23
   })

   employees.push({
       name:'Tea',
       age:45
   })

   employees.push({
       name:'Lee',
       age:31
   })

   employees.push({
       name:'Lea',
       age:67
   })

</script>
</html>